//WY3 小易的升级之路


#include <iostream>
#include <vector>
using namespace std;

int gcd(int x, int y)
{
    int a = x, b = y, c = 0;
    while((c = a % b))
    {
        a = b;
        b = c;
    }
    return b;
}
int main()
{
    int n = 0, a = 0;
    while(cin >> n >> a)
    { 
        vector<int> v(n, 0);
        for(int i = 0; i < n; i++)
        {
            cin >> v[i];
            if(v[i] <= a) a += v[i];
            else a += gcd(v[i], a);
        }
        cout << a << endl;
    }

    return 0;
}